package com.djl.rabbitmq.two;

import com.djl.rabbitmq.utils.RabbitMqUtils;
import com.rabbitmq.client.Channel;

import java.util.Scanner;

/**
 * @program: rabbitmq-hello
 * @description: 生产者
 * @author: Mr.dai
 * @create: 2021-09-10 11:12
 **/

public class Task01 {
    //队列名称
    private static final String QUEUE_NAME="hello";

    public static void main(String[] args) throws Exception {
        Channel channel = RabbitMqUtils.getChannel();
        //进行队列的声明
        channel.queueDeclare(QUEUE_NAME,true,false,false,null);
        //从控制台接收信息
        Scanner scanner=new Scanner(System.in);
        while (scanner.hasNext()){
            String next = scanner.next();
            channel.basicPublish("",QUEUE_NAME,null,next.getBytes());
            System.out.println("发送消息完成："+next);
        }


    }
}
